<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <style>
/*
 * Base structure
 */

/* Move down content because we have a fixed navbar that is 50px tall */
body {
  padding-top: 50px;
}


/*
 * Global add-ons
 */

.sub-header {
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/*
 * Top navigation
 * Hide default border to remove 1px line.
 */
.navbar-fixed-top {
  border: 0;
}

/*
 * Sidebar
 */

/* Hide for mobile, show later */
.sidebar {
  display: none;
}
@media (min-width: 768px) {
  .sidebar {
    position: fixed;
    top: 51px;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: block;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
    background-color: #f5f5f5;
    border-right: 1px solid #eee;
  }
}

/* Sidebar navigation */
.nav-sidebar {
  margin-right: -21px; /* 20px padding + 1px border */
  margin-bottom: 20px;
  margin-left: -20px;
}
.nav-sidebar > li > a {
  padding-right: 20px;
  padding-left: 20px;
}
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
  color: #fff;
  background-color: #428bca;
}


/*
 * Main content
 */

.main {
  padding: 20px;
}
@media (min-width: 768px) {
  .main {
    padding-right: 40px;
    padding-left: 40px;
  }
}
.main .page-header {
  margin-top: 0;
}


/*
 * Placeholder dashboard ideas
 */

.placeholders {
  margin-bottom: 30px;
  text-align: center;
}
.placeholders h4 {
  margin-bottom: 0;
}
.placeholder {
  margin-bottom: 20px;
}
.placeholder img {
  display: inline-block;
  border-radius: 50%;
}
    </style>
</head>
<body>
    
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="###">SIM管理</a>
          </div>
          <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
              <li><a href="/">短信记录</a></li>
              <li><a href="/send-sms">发送短信</a></li>
              <li><a href="#">功能</a></li>
              <li><a href="#">帮助</a></li>
            </ul>
            <form class="navbar-form navbar-right hide">
              <input type="text" class="form-control" placeholder="Search...">
            </form>
          </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">
            <div class="btn-group btn-group-justified" data-toggle="buttons">
                <label class="btn btn-swith-state btn-success active" data-state="0">
                    <input type="radio" name="state" id="option1" checked> 全部的（默认）
                </label>
                <label class="btn btn-swith-state btn-success" data-state="1">
                    <input type="radio" name="state" id="option2"> 未读的
                </label>
                <label class="btn btn-swith-state btn-success" data-state="2">
                    <input type="radio" name="state" id="option3"> 已读的
                </label>
            </div>
        </div>
        <div class="row">
            <div class="table-responsive">
                <table class="table" id="data_table">
                    <thead>
                        <tr>
                        <th>#</th>
                        <th>发件人号码</th>
                        <th>收件时间</th>
                        <th>短信内容</th>
                    </tr>
                    </thead>
                    <tbody id="data_table_body">
                        <tr>
                            <td>1</td>
                            <td>10010</td>
                            <td>2024-01-24 11:00:11</td>
                            <td><p>Window10_LTSC2021_19044.3803_X64_纯净[深度精简版][1.26G](2023.12.15).esd</p></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<script>
    function loadDataList(state){
        $.getJSON("/sms/rest/sms/list", {"state": state}, function(result){
            if(result != null && result.code == 200){
                $("#data_table_body").empty();
                let dom = [];
                $.each(result.data, function(i,j){
                    dom.push('<tr>');
                    dom.push('<td>'+j.id+'</td>');
                    dom.push('<td>'+j.sender+'</td>');
                    dom.push('<td>'+j.recieve_time+'</td>');
                    dom.push('<td>' + j.content + '</td>');
                    dom.push('</tr>');
                });
                $("#data_table_body").append(dom.join(''));
            }
        });
    }
    $(function(){
        loadDataList(0);
        $(".btn-swith-state").click(function(){
            let txt = $(this).text();
            let state = $(this).data("state");
            document.title = txt;
            $(this).siblings().removeClass("active");
            $(this).addClass("active");
            loadDataList(state);
        });
    });
</script>
</body>
</html>